//
//  ScreenLayout.m
//  coyote
//
//  Created by jenkins on 2022/9/13.
//  Copyright © 2022 500wan. All rights reserved.
//

#import "ScreenLayout.h"
#import <UIKit/UIKit.h>



static UIEdgeInsets ScreenLayout_safeAreaInsets;
@implementation ScreenLayout

+(void)load{
    if (@available(iOS 11.0, *)) {
        ScreenLayout_safeAreaInsets = [[UIWindow alloc] init].safeAreaInsets;
    } else {
        ScreenLayout_safeAreaInsets = UIEdgeInsetsMake(20, 0, 0, 0);
        // Fallback on earlier versions
    }
}


+(CGFloat) safeTop{
    return MAX(ScreenLayout_safeAreaInsets.top, 20);
}
+(CGFloat) safeBottom{
    return ScreenLayout_safeAreaInsets.bottom;
}
+(CGFloat) safeLeft{
    return ScreenLayout_safeAreaInsets.left;
}
+(CGFloat) safeRight{
    return ScreenLayout_safeAreaInsets.right;
}


+(CGFloat) layoutScreenSizeWith375XSize:(CGFloat) size{

    return [self layoutScreenSizeWith375XSize:size scaleStyle:(LayoutScreenScaleStyleSingle)];
    
}
+(CGFloat) layoutScreenDoubleScaleSizeWith375XSize:(CGFloat) size{
    
    return [self layoutScreenSizeWith375XSize:size scaleStyle:(LayoutScreenScaleStyleDouble)];
}
//经过等比例转化之后， font的高度和宽度也会接近等比例，只有在英文的时候会有明显一些误差。
+(CGFloat) layoutScreenSizeWith375XSize:(CGFloat) size scaleStyle:(LayoutScreenScaleStyle) scaleStyle{
    return (CGFloat)((NSInteger)(size / 375 * (kScreenWidth) * [[UIScreen mainScreen] scale] * scaleStyle)) / [[UIScreen mainScreen] scale] / scaleStyle;
}

+(CGFloat) lineSize{
    return 1 / [[UIScreen mainScreen] scale];
}
@end
